#pragma once
#include "dataTypes.h"

class Transition
{
	public:
		Transition(bool* aIsDynamic)
		{
			isDynamic = aIsDynamic;
			Reset();
		}

		void Reset()
		{
			transitionType = TRANSITION_NONE;
			transitionState = TRANSITION_STATE_OFF;
			percentDone = 0;
			step = 0.02;
			autoOff = false;
		}

		ETransition GetType()
		{
			return transitionType;
		}

		ETransitionState GetState()
		{
			return transitionState;
		}

		float GetPercentDone()
		{
			return percentDone;
		}
		
		bool IsInOrOut()
		{
			return inOrOut;
		}

		void StartTransition(ETransition aType, bool aInOrOut, float aSpeed, bool aAutoOff = false)
		{
			Reset();
			transitionType = aType;
			transitionState = TRANSITION_STATE_ON;
			inOrOut = aInOrOut;
			step *= aSpeed;
			autoOff = aAutoOff;
			*isDynamic = false;
		}

		void Tick()
		{
			if(transitionState == TRANSITION_STATE_ON)
			{
				percentDone += step;
				if(percentDone >= 1)
				{
					percentDone = 1;
				  if(autoOff) transitionState = TRANSITION_STATE_OFF;
					else transitionState = TRANSITION_STATE_DONE;
					*isDynamic = true;
				}
			}
		}

	private:
		ETransition transitionType;
		ETransitionState transitionState;
		float percentDone;
		float step;
		bool inOrOut;
		bool autoOff;

		bool* isDynamic;
};

